# 上一个程序超出时间限制了
# Sunday解法
import sys

haystack = "ababbbbaaabbbaaa"
needle = "bbbb"

index = 0
haystack = list(haystack)
needle = list(needle)
while 1:
    if haystack[index:index + len(needle)] == needle:

        print(index)
        sys.exit(0)
    else:
        if index + len(needle) > len(haystack) - 1:
            print("不能匹配")

        if haystack[index + len(needle)] not in needle:
            index = index + len(needle)

        else:
            index = index + 1
            if index + 1 > len(haystack) - 1:
                print("不能匹配")
